package com.syni.mdd.yhd.common.all.controller.protect.business;

/**
 * @className BmsBusinessController
 * @description TOO
 * @Author cfx
 * @DATE 2019/4/15 14:25
 * @VERSION 1.0
 **/
import com.syni.mdd.sjb.common.component.utils.common.annotations.CheckParams;
import com.syni.mdd.yhd.common.all.constants.Constants;
import com.syni.mdd.yhd.common.all.entity.BmsBusinessType;
import com.syni.mdd.yhd.common.all.service.BmsBusinessTypeService;
import com.syni.mdd.sjb.common.component.utils.common.utils.ParamsMap;
import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/businessType")
public class BmsBusinessTypeController {
    @Autowired
    BmsBusinessTypeService bmsBusinessTypeService;

    @GetMapping("/getBusinessType")
    public Map<String,Object> getBusinessType(){
        List<BmsBusinessType> bmsBusinessTypeList = bmsBusinessTypeService.getBaseDao().findByIsDelete(Integer.parseInt(Constants.COMMON_FLAG_FALSE));
        if(bmsBusinessTypeList != null & bmsBusinessTypeList.size() > 0){
            return ResultMapHelper.success(bmsBusinessTypeList,"获取成功！");
        }
        return ResultMapHelper.failure("获取失败！");
    }

    @PostMapping("/getBusinessType")
    @CheckParams(params = {"page_num","page_size"},checkAuth = true)
    public Map<String,Object> getBusinessTypeimproveImprove(@RequestBody ParamsMap paramMap){
        return bmsBusinessTypeService.findBusinessType(paramMap);
    }

    @PostMapping("/getBusinessTypeAndLabel")
    public Map<String,Object> getBusinessTypeAndLabel(@RequestBody ParamsMap paramMap){
        //long b = System.currentTimeMillis();
        Map<String,Object> obj  = bmsBusinessTypeService.getBusinessTypeAndLabel(paramMap);
        //long c = System.currentTimeMillis();
        //System.out.println("消耗 ： " + (c - b));
        return obj;
    }


}
